package cn.bootdu.plugin.oss;

import cn.bootdu.plugin.oss.properties.OssProperties;
import cn.bootdu.plugin.oss.template.OssTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * oss 自动配置类
 *
 * @author duxsheng
 * @since 1.0
 */
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties({OssProperties.class})
@ConditionalOnProperty(prefix = OssProperties.PREFIX, name = "enable", havingValue = "true")
public class OssAutoConfiguration {

    /**
     * oss操作模板
     *
     * @param properties oss配置
     * @return OssTemplate
     */
    @Bean
    @ConditionalOnMissingBean(OssTemplate.class)
    public OssTemplate ossTemplate(OssProperties properties) {
        return new OssTemplate(properties);
    }

}
